class Base {
  constructor(data, message) {
    if (typeof data === 'string') {
      this.message = this.data
      this.data = null;
      this.message = null;
    }
    if (data) {
      this.data = data
    }
    if (message) {
      this.message = message;
    }
  }  
}

class SuccessModel extends Base {
  constructor(data, message) {
    super(data, message)
    this.errno = 0;
  }
}

class FailModel extends Base {
  constructor(data, message) {
    super(data, message)
    this.errno = -1;
  }
}

module.exports = {
  success() {
    const config = {
      errno: 0,
    }
    return {...config}
  },
  fail () {
    return {
      errno: -1
    }
  }
}